
export function onLocationChange(params) {
    debugger
    if (!params) {
        return
    }

    const { gridCode, lat, lng, address } = params;
    const districtEle = this.$$("single_select_fpzt06");
    const streetEle = this.$$("single_select_ffyt0n");
    const communityEle = this.$$("single_select_eqj6ji");
    // const communityEle = this.$$("single_select_6q2kn3");

    const regionId = this.$$("number_input_cq8p2c");
    this.$$("text_input_6nhu1k").cValue = address;
    this.$$("text_input_6nhu1k").onChange();

    // 调用mis的api接口
    let paramsValue = [{ name: "cellCode", valueContent: gridCode.slice(0, -3) }];
    api.DATA_SOURCE_EXECUTE("4b089e62-2a5b-487b-ba61-671e6bd223c1", "ddcat", paramsValue, [], "").then(res => {
        if (!res.hasError) {
            const data = res.result;
            if (data.length > 0) {
                const { districtId, streetId, communityId } = data[0];
                // district 区域信息
                // street 街道信息
                // community 社区信息
                districtEle.$$setValue(streetId);
                districtEle.onChange();
                streetEle.$$setValue(communityId);
                streetEle.onChange();
                communityEle.$$setValue(districtId);
                streetEle.onChange();

                regionId.$$setValue(streetId);
                regionId.onChange();

            }
        }
    }).catch(err => {
        console.error(err);
    });

}


function main(){
    let regionId = this.cValue;
    this.$$("number_input_cq8p2c").cValue = regionId;
    this.$$("number_input_cq8p2c").onChange();
}
